﻿@page "/usercenter"

@inherits BaseComponentBase
@attribute [Authorize]
@attribute [IgnoreRolePermission]
@namespace ThingsGateway.Admin.Blazor
@using Microsoft.AspNetCore.Authorization;
@using ThingsGateway.Admin.Application;
@using ThingsGateway.Core.Extension
@inject UserResoures UserResoures


<MCard Rounded=true Elevation=1 Class="ma-2">

    <MTabs @bind-Value="tab" Class="">
        <MTab Value=1>   @AppService.I18n.T("基础信息")    </MTab>
        <MTab Value=2>    @AppService.I18n.T("修改密码")    </MTab>
        <MTab Value=3>    @AppService.I18n.T("快捷方式")    </MTab>
        <MTab Value=4>    @AppService.I18n.T("主页设置")    </MTab>
    </MTabs>

    <MTabsItems Value="tab">
        <MTabItem Value="1">
            <MCard Flat Elevation="0" Class="ma-5">

                 <MTextField Style="max-width:300px;" Class="mt-3 mr-3" Dense HideDetails=@("auto") Clearable Outlined
                             Label=@AppService.I18n.T(_updateInfoInput.Description(it => it.Phone)) @bind-Value=@_updateInfoInput.Phone />
                 <MTextField Style="max-width:300px;" Class="mt-3 mr-3" Dense HideDetails=@("auto") Clearable Outlined
                             Label=@AppService.I18n.T(_updateInfoInput.Description(it => it.Email)) @bind-Value=@_updateInfoInput.Email />
                 <MCardActions>
                     <MButton Class="ml-2 mt-5 mb-2" OnClick=OnUpdateUserInfoAsync Color="primary">
                         @AppService.I18n.T("保存")
                    </MButton>
                </MCardActions>
            </MCard>
        </MTabItem>

        <MTabItem Value="2">
            <MCard Flat Elevation="0" Class="ma-5">
                 <MForm Model="_passwordInfoInput" EnableValidation>

                    <MTextField Style="max-width:300px;" Class="mt-3 mr-3" Dense HideDetails=@("auto") Clearable Outlined
                                 Label=@AppService.I18n.T(_passwordInfoInput.Description(it => it.Password)) @bind-Value=@_passwordInfoInput.Password />
                     <MTextField Style="max-width:300px;" Class="mt-3 mr-3" Dense HideDetails=@("auto") Clearable Outlined
                                 Label=@AppService.I18n.T(_passwordInfoInput.Description(it => it.NewPassword)) @bind-Value=@_passwordInfoInput.NewPassword />
                     <MTextField Style="max-width:300px;" Class="mt-3 mr-3" Dense HideDetails=@("auto") Clearable Outlined
                                 Label=@AppService.I18n.T(_passwordInfoInput.Description(it => it.ConfirmPassword)) @bind-Value=@_passwordInfoInput.ConfirmPassword />

                     <MCardActions>
                         <MButton Type="submit" Class="ml-2 mt-5 mb-2" OnClick=@(()=>OnUpdatePasswordInfoAsync(context)) Color="primary">
                             @AppService.I18n.T("保存")
                        </MButton>
                    </MCardActions>
                </MForm>
            </MCard>
        </MTabItem>
        <MTabItem Value="3">
            <MCard Flat Elevation="0" Class="ma-5">

                 <MTreeview Class="ml-3 mt-6" Dense OpenAll TItem="SysResource" TKey="long" Selectable @bind-Value="_menusChoice.WorkbenchData"
                           OpenOnClick Items="UserResoures.UserMenus" ItemText="r=>r.Title" ItemChildren="r=>r.Children" ItemKey=@(r=>r.Id) />

                 <MCardActions>
                     <MButton Class="ml-2 mt-5 mb-2" OnClick=OnShortcutSaveAsync Color="primary">
                         @AppService.I18n.T("保存")
                    </MButton>
                </MCardActions>
            </MCard>


        </MTabItem>

        <MTabItem Value="4">
            <MCard Flat Elevation="0" Class="ma-5">

                 <MSelect Class="ml-3 mt-6" Items="UserResoures.UserWorkbenchOutputs" Style="max-width:400px;"
                          @bind-Value="@_defaultMenuId.DefaultRazorData"
                          MenuProps="@(props => { props.Auto = true; props.OffsetY = true; })"
                          ItemText="u => u.Title"
                          ItemValue="u => u.Id"
                         Dense
                         Outlined></MSelect>

                 <MCardActions>
                     <MButton Class="ml-2 mt-5 mb-2" OnClick=@(()=>OnDefaultRazorSaveAsync()) Color="primary">
                         @AppService.I18n.T("保存")
                    </MButton>
                </MCardActions>

            </MCard>


        </MTabItem>


    </MTabsItems>


</MCard>


@code {
    StringNumber tab;
}

